<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>微服务管理系统</title>
		<!-- Tell the browser to be responsive to screen width -->
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<!-- Bootstrap 3.3.7 -->
		<link rel="stylesheet" href="../../bower_components/bootstrap/dist/css/bootstrap.min.css">
		<!-- Font Awesome -->
		<link rel="stylesheet" href="../../bower_components/font-awesome/css/font-awesome.min.css">
		<!-- Ionicons -->
		<link rel="stylesheet" href="../../bower_components/Ionicons/css/ionicons.min.css">
		<!-- DataTables -->
		<link rel="stylesheet" href="../../bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<!-- Theme style -->
		<link rel="stylesheet" href="../../dist/css/AdminLTE.min.css">
		<!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
		<link rel="stylesheet" href="../../dist/css/skins/_all-skins.min.css">

		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

		<!-- Google Font -->
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
		<style>
			body,
			td {
				font-size: 15px !important;
				/*font-weight:600*/
			}
			
			;
		</style>
	</head>

	<body class="hold-transition skin-blue sidebar-mini">
		<div class="wrapper">

			<header class="main-header">
				<!-- Logo -->
				<a href="#" class="logo">
					<!-- mini logo for sidebar mini 50x50 pixels -->
					<span class="logo-mini"><b>微</b>服务</span>
					<!-- logo for regular state and mobile devices -->
					<span class="logo-lg"><b>微服务</b>管理系统</span>
				</a>
				<!-- Header Navbar: style can be found in header.less -->
				<nav class="navbar navbar-static-top">
					<!-- Sidebar toggle button-->
					<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
						<span class="sr-only">Toggle navigation</span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</a>

					<div class="navbar-custom-menu">
						<ul class="nav navbar-nav">
							<!-- User Account: style can be found in dropdown.less -->
							<li class="dropdown user user-menu">
								<a href="#" class="dropdown-toggle" data-toggle="dropdown">
									<img src="../../dist/img/user2-160x160.jpg" class="user-image" alt="User Image">
									<span class="hidden-xs">admin</span>
								</a>
							</li>
							<!-- Control Sidebar Toggle Button -->
						</ul>
					</div>
				</nav>
			</header>
			<!-- Left side column. contains the logo and sidebar -->
			<aside class="main-sidebar">
				<!-- sidebar: style can be found in sidebar.less -->
				<section class="sidebar">
					<!-- Sidebar user panel -->
					<div class="user-panel">
						<div class="pull-left image">
							<img src="../../dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
						</div>
						<div class="pull-left info">
							<p>admin</p>
							<a href="#"><i class="fa fa-circle text-success"></i> Online</a>
						</div>
					</div>
					<!-- sidebar menu: : style can be found in sidebar.less -->
					<ul class="sidebar-menu" data-widget="tree">
						<li class="treeview active">
							<a href="#">
								<i class="fa fa-table"></i> <span>列表</span>
								<span class="pull-right-container">
				                  <i class="fa fa-angle-left pull-right"></i>
				                </span>
							</a>
							<ul class="treeview-menu">
								<li>
									<a href="list_page.html"><i class="fa fa-circle-o"></i>内部服务列表页</a>
								</li>
								<li>
									<a href="outside_list_page.html"><i class="fa fa-circle-o"></i>外部服务列表页</a>
								</li>
								<li>
									<a href="dock_party_page.html"><i class="fa fa-circle-o"></i>接入方列表</a>
								</li>
								<li>
									<a href="user_authority.html"><i class="fa fa-circle-o"></i>用户权限管理</a>
								</li>
							</ul>
						</li>
						<li class="treeview active">
							<a href="#">
								<i class="fa fa-edit"></i> <span>表单</span>
								<span class="pull-right-container">
				                  <i class="fa fa-angle-left pull-right"></i>
				                </span>
							</a>
							<ul class="treeview-menu">
								<li>
									<a href="test_service.html"><i class="fa fa-tumblr"></i>内部服务测试</a>
								</li>
							</ul>
						</li>
					</ul>
				</section>
				<!-- /.sidebar -->
			</aside>

			<!-- Content Wrapper. Contains page content -->
			<div class="content-wrapper">
				<!-- Content Header (Page header) -->
				<section class="content-header">
					<h1>微服务管理系统</h1>
					<ol class="breadcrumb">
						<li><i class="fa fa-dashboard"></i> 主页</ a>
						</li>
						<li>内部服务</li>
						<li class="active">内部服务测试</li>
					</ol>
				</section>

				<!-- Main content -->
				<section class="content">
					<div class="row">
						<div class="col-xs-12">
							<div class="box">
								<div class="box-header">
									<h3 class="box-title">内部服务测试</h3>
								</div>
								<!-- /.box-header -->
								<div class="box-body">
									<form id="addServer" class="form-horizontal">
										<div class="box-body">
											<label for="serviceName" class="col-sm-3 control-label">服务名称</label>
											<div class="form-group">
												<div class="col-sm-7">
													<select type="text" class="form-control" name="serviceName" id="serviceName"></select>
												</div>
											</div>
											<label for="serviceData" class="col-sm-3 control-label">服务参数</label>
											<div class="form-group">
												<div class="col-sm-7">
													<textarea type="text" class="form-control" name="serviceData" id="serviceData" rows="5"></textarea>
												</div>
											</div>
											<label for="name" class="col-sm-3 control-label"></label>
											<div class="form-group">
												<div class="col-sm-7">
													<input type="button" class="form-control btn-primary" value="测试" onclick="testService();">
												</div>
											</div>
											<label for="serviceReturn" class="col-sm-3 control-label">服务测试返回值</label>
											<div class="form-group">
												<div class="col-sm-7">
													<textarea type="text" class="form-control" name="serviceReturn" id="serviceReturn" rows="13"></textarea>
												</div>
											</div>
										</div>
									</form>
								</div>
								<!-- /.box-body -->
							</div>
							<!-- /.box -->
						</div>
						<!-- /.col -->
					</div>
					<!-- /.row -->
				</section>
				<!-- /.content -->
			</div>
		</div>
		<!-- ./wrapper -->
		<!-- jQuery 3 -->
		<script src="../../bower_components/jquery/dist/jquery.min.js"></script>
		<!-- Bootstrap 3.3.7 -->
		<script src="../../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<!-- DataTables -->
		<script src="../../bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
		<script src="../../bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
		<!-- SlimScroll -->
		<script src="../../bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
		<!-- FastClick -->
		<script src="../../bower_components/fastclick/lib/fastclick.js"></script>
		<!-- AdminLTE App -->
		<script src="../../dist/js/adminlte.min.js"></script>
		<!-- AdminLTE for demo purposes -->
		<script src="../../dist/js/demo.js"></script>
		<script src="common.js"></script>
		<!-- page script -->
		<script>
			$(document).ready(function () {
		        fn_initServiceName();
		    });
		    // 进入页面初始化内服服务下拉框
		    function fn_initServiceName() {
		        $.ajax({
		            url: apiUrl,
					type: "POST",
					contentType: "application/json;charset=utf-8",
					dataType: "json",
					data: JSON.stringify(
							{
							    "Head": {
							        "ApiName": "getServiceList",
							        "Model":"debug"
							    },
							}),
					dataSrc:"Body",
		            success: function (result) {
		                $.each(result.Body, function (index, item) {
		                    var optDom=$('<option></option>');
		                    optDom.val(item.name);
		                    optDom.html(item.desc);
		                    $("#serviceName").append(optDom);
		                });
		            },
		            error: function (msg) {
		            	alert("系统繁忙，请稍后重试");
		            }
		        });
		    };
		    
		    // 测试，将输入框数据组装发送测试
		    function testService(){
		    	var serviceData = $("#serviceData").val();
		    	//serviceData = JSON.stringify({"apiName":"0000","tagName":"0"})
		    	if(serviceData == "" || serviceData == undefined || serviceData == null){
		    		serviceData = "{}";
		    	}
		    	
		    	try{
                    serviceData = JSON.parse(serviceData);
                }catch(e){
                    alert("json 格式错误!!!请检查参数")
                    return ;
                }
		    	
		    	var serviceName = $("#serviceName").val();
		    	$.ajax({
		            url: apiUrl,
					type: "POST",
					contentType: "application/json;charset=utf-8",
					dataType: "json",
					data: JSON.stringify(
							{
							    "Head": {
							        "ApiName": "serviceTestApi",
							        "Model":"debug"
							    },
							     "Body":{
							     "serviceName":serviceName,
							     "serviceData":serviceData
							    }
							}),
					dataSrc:"Body",
		            success: function (result) {
		            	//$("#serviceReturn").val(JSON.stringify(result));
		            	$("#serviceReturn").val(getFormatData(JSON.stringify(result)));
		                
		            },
		            error: function (msg) {
		            	alert("系统繁忙，请稍后重试");
		            }
		        });
		    };
		</script>
	</body>

</html>